make build
# gcc evenadd.c -o evenodd -O3 -DTEST
rm -r disk_*
dd if=/dev/urandom of=test_file1.dat bs=1M count=64
dd if=/dev/urandom of=test_file2.dat bs=1M count=64
dd if=/dev/urandom of=test_file3.dat bs=1M count=64
dd if=/dev/urandom of=test_file4.dat bs=1M count=64
dd if=/dev/urandom of=test_file5.dat bs=1M count=64
dd if=/dev/urandom of=test_file6.dat bs=1M count=64
dd if=/dev/urandom of=test_file7.dat bs=1M count=64
dd if=/dev/urandom of=test_file8.dat bs=1M count=64
./evenodd write 7 test_file1.dat d0
./evenodd write 7 test_file2.dat d1
./evenodd write 7 test_file3.dat d2
./evenodd write 7 test_file4.dat d3
./evenodd write 7 test_file5.dat d4
./evenodd write 7 test_file6.dat d5
./evenodd write 7 test_file7.dat d6
./evenodd write 7 test_file8.dat d7
./evenodd read 7 d0 res_file1.dat
./evenodd read 7 d1 res_file2.dat
diff res_file1.dat test_file1.dat
diff res_file2.dat test_file2.dat
echo "pass1"
rm -r disk_1 disk_4
./evenodd read 7 d0 res_file1.dat
./evenodd read 7 d1 res_file2.dat
diff res_file1.dat test_file1.dat
diff res_file2.dat test_file2.dat
echo "pass2"
rm -r disk_2 disk_5
./evenodd repair 7 2 5
./evenodd read 7 d0 res_file1.dat
./evenodd read 7 d1 res_file2.dat
diff res_file1.dat test_file1.dat
diff res_file2.dat test_file2.dat
echo "pass3"
rm -r disk_3 disk_7
./evenodd repair 7 3 7
./evenodd read 7 d0 res_file1.dat
./evenodd read 7 d1 res_file2.dat
diff res_file1.dat test_file1.dat
diff res_file2.dat test_file2.dat
echo "pass4"
rm -r disk_6 disk_8
./evenodd repair 7 6 8
./evenodd read 7 d0 res_file1.dat
./evenodd read 7 d1 res_file2.dat
diff res_file1.dat test_file1.dat
diff res_file2.dat test_file2.dat
echo "pass5"
rm -r disk_4
./evenodd repair 7 4
./evenodd read 7 d0 res_file1.dat
./evenodd read 7 d1 res_file2.dat
diff res_file1.dat test_file1.dat
diff res_file2.dat test_file2.dat
echo "pass6"
rm -r disk_7
./evenodd repair 7 7
./evenodd read 7 d0 res_file1.dat
./evenodd read 7 d1 res_file2.dat
diff res_file1.dat test_file1.dat
diff res_file2.dat test_file2.dat
echo "pass7"
rm -r disk_8
./evenodd repair 7 8
./evenodd read 7 d0 res_file1.dat
./evenodd read 7 d1 res_file2.dat
diff res_file1.dat test_file1.dat
diff res_file2.dat test_file2.dat
echo "pass8"
rm -r disk_7 disk_8
./evenodd repair 7 7 8
./evenodd read 7 d0 res_file1.dat
./evenodd read 7 d1 res_file2.dat
diff res_file1.dat test_file1.dat
diff res_file2.dat test_file2.dat
echo "pass9"
echo "all tests passed"
rm -f *.dat
rm -r disk_*